* Graph shooting-related news coverage around time of mass shootings

clear all
set more off

cap mkdir "results"
cap mkdir "results/fig"

// grid style for plots
loc gstyle "grid glwidth(vthin) glcolor(gs12) glpattern(shortdash)"


// graph pattern around time of shooting
use "out-data/gun_news.dta", clear

collapse (mean) duration (semean) semean=duration, by(time) fast
gen float lb = duration - 1.96 * semean
gen float ub = duration + 1.96 * semean


twoway (connected duration time, msize(small) mcolor(black) lcolor(black)) /*
    */ (line lb ub time, lcolor(black black) lpattern(longdash longdash) lwidth(thin thin)) /*
    */ , name(all, replace) xsize(6) ysize(3) /*
    */   ylabel(0(100)400, labsize(small) `gstyle') /*
    */   ytitle("Average Seconds of News Coverage", size(medsmall) height(5)) /*
    */   xline(0, lpattern(solid) lcolor(gs6)) /*
    */   xlabel(-16(2)16, labsize(small)) /*
    */   xtitle("Days Relative to Mass Shooting", size(medsmall) height(5)) /*
    */   graphregion(color(white)) plotregion(margin(tiny)) legend(off)

graph export "results/fig/shoot_coverage.pdf", replace


// graph patterns for different fatality counts
use "out-data/gun_news.dta", clear

collapse (mean) duration (semean) semean=duration, by(time tfgrp) fast
gen float lb = duration - 1.96 * semean
gen float ub = duration + 1.96 * semean

twoway (connected duration time if tfgrp == 1, /*
    */     msize(small) mcolor(black) lcolor(black)) /*
    */ (connected duration time if tfgrp == 2, /*
    */     msize(small) mcolor(black) mfc(white) lcolor(black) lpattern(dash)) /*
    */ (connected duration time if tfgrp == 3, /*
    */     m(t) msize(medsmall) mcolor(gs6) lcolor(black) lpattern(longdash)) /*
    */ , name(fat, replace) xsize(6) ysize(3) /*
    */ ylabel(0(500)2000, labsize(small) `gstyle') /*
    */   ytitle("Average Seconds of News Coverage", size(medsmall) height(5)) /*
    */   xline(0, lpattern(solid) lcolor(gs6)) /*
    */   xlabel(-16(2)16, labsize(small)) /*
    */   xtitle("Days Relative to Mass Shooting", size(medsmall) height(5)) /*
    */   graphregion(color(white)) plotregion(margin(tiny)) /*
    */   legend(order(1 2 3) col(1) ring(0) pos(10) size(medsmall) /*
    */          label(1 "4-5 Fatalities") /*
    */          label(2 "6-9 Fatalities") /*
    */          label(3 "10+ Fatalities"))

graph export "results/fig/shoot_fatality_groups.pdf", replace
exit
